package com.mx102.kosmos;

import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL11;

public class Background {
	
	private Sprite[] star;
	private int num;
	
	public Background(int x,int y,int num) {
		
		this.num=num;
		
		star=new Sprite[num];
		
		for(int i=0;i<num;i++) {
			double rand=Math.random();
			if(rand<0.33) star[i]=new Sprite("star1.png",(float)(Math.random()+0.2));
			else if(rand<0.66) star[i]=new Sprite("star2.png",(float)(Math.random()+0.2));
			else star[i]=new Sprite("star3.png",(float)(Math.random()+0.3));
			
			
			star[i].setPosition((float)(-400*Math.random()+200), (float)(-320*Math.random()+20),-20);
			
		
		}
		
		
	}

	public void render(GL11 gl,float delta,Camera oCam) {
		for(int i=0;i<num;i++) {
			star[i].move(0, 100*delta);
			if(star[i].getY()>70) star[i].setPosition((float)(-200*Math.random()+100), (float)(-300-Math.random()*50),-20);
			star[i].render(gl,oCam);
		}
		
	}
}
